From 696f54a804b6bece727271e9adc9c39ee12231be Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 27 May 2004 04:46:42 +0000 Subject: [PATCH] Make GtkEntryCompletion::text_column a property. --- ChangeLog | 6 +++ ChangeLog.pre-2-10 | 6 +++ ChangeLog.pre-2-6 | 6 +++ ChangeLog.pre-2-8 | 6 +++ docs/reference/ChangeLog | 9 ++++ docs/reference/gtk/gtk-sections.txt | 1 + .../gtk/tmpl/gtkentrycompletion.sgml | 7 ++- gtk/gtkentrycompletion.c | 53 +++++++++++++++++-- gtk/gtkentrycompletion.h | 1 + 9 files changed, 90 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a9a138b99..bede3d6f9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu May 27 00:45:07 2004 Matthias Clasen + + * gtk/gtkentrycompletion.h: + * gtk/gtkentrycompletion.c (gtk_entry_completion_get_text_column): + Getter for text_column. Also make ::text_column a property. + Thu May 27 00:11:01 2004 Matthias Clasen * gtk/gtkmenuitem.c (gtk_menu_item_size_request): Fix a typo. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 1a9a138b99..bede3d6f9f 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Thu May 27 00:45:07 2004 Matthias Clasen + + * gtk/gtkentrycompletion.h: + * gtk/gtkentrycompletion.c (gtk_entry_completion_get_text_column): + Getter for text_column. Also make ::text_column a property. + Thu May 27 00:11:01 2004 Matthias Clasen * gtk/gtkmenuitem.c (gtk_menu_item_size_request): Fix a typo. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 1a9a138b99..bede3d6f9f 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Thu May 27 00:45:07 2004 Matthias Clasen + + * gtk/gtkentrycompletion.h: + * gtk/gtkentrycompletion.c (gtk_entry_completion_get_text_column): + Getter for text_column. Also make ::text_column a property. + Thu May 27 00:11:01 2004 Matthias Clasen * gtk/gtkmenuitem.c (gtk_menu_item_size_request): Fix a typo. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 1a9a138b99..bede3d6f9f 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Thu May 27 00:45:07 2004 Matthias Clasen + + * gtk/gtkentrycompletion.h: + * gtk/gtkentrycompletion.c (gtk_entry_completion_get_text_column): + Getter for text_column. Also make ::text_column a property. + Thu May 27 00:11:01 2004 Matthias Clasen * gtk/gtkmenuitem.c (gtk_menu_item_size_request): Fix a typo. diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index cf25269c70..5c4968f631 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,12 @@ +Thu May 27 00:44:48 2004 Matthias Clasen + + * gtk/gtk-sections.txt: Add gtk_entry_completion_get_text_column. + +Thu May 27 00:20:52 2004 Matthias Clasen + + * gtk/tmpl/gtkentrycompletion.sgml: Add notes about + GtkEntryCompletionMatchFunc. + Tue May 25 21:54:55 2004 Matthias Clasen * gtk/tmpl/gtkframe.sgml: Move docs inline. diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 664fc9f9d6..e854726240 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -1047,6 +1047,7 @@ gtk_entry_completion_insert_action_text gtk_entry_completion_insert_action_markup gtk_entry_completion_delete_action gtk_entry_completion_set_text_column +gtk_entry_completion_get_text_column GTK_TYPE_ENTRY_COMPLETION GTK_ENTRY_COMPLETION diff --git a/docs/reference/gtk/tmpl/gtkentrycompletion.sgml b/docs/reference/gtk/tmpl/gtkentrycompletion.sgml index 48f525e951..ddbc41625c 100644 --- a/docs/reference/gtk/tmpl/gtkentrycompletion.sgml +++ b/docs/reference/gtk/tmpl/gtkentrycompletion.sgml @@ -80,11 +80,14 @@ The GtkEntryCompletion struct contains only private data. A function which decides whether the row indicated by @iter matches a given -@key, and should be displayed as a possible completion for @key. +@key, and should be displayed as a possible completion for @key. Note that +@key is normalized and case-folded (see g_utf8_normalize() and +g_utf8_casefold()). If this is not appropriate, match functions have access +to the unmodified key via gtk_entry_get_text (GTK_ENTRY (gtk_entry_completion_get_entry ())). @completion: the #GtkEntryCompletion -@key: the string to match +@key: the string to match, normalized and case-folded @iter: a #GtkTreeIter indicating the row to match @user_data: user data given to gtk_entry_completion_set_match_func() @Returns: %TRUE if @iter should be displayed as a possible completion for @key diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index d7cd492b92..b50549cd52 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -51,7 +51,8 @@ enum { PROP_0, PROP_MODEL, - PROP_MINIMUM_KEY_LENGTH + PROP_MINIMUM_KEY_LENGTH, + PROP_TEXT_COLUMN }; #define GTK_ENTRY_COMPLETION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ENTRY_COMPLETION, GtkEntryCompletionPrivate)) @@ -238,6 +239,22 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass) G_MAXINT, 1, G_PARAM_READWRITE)); + /** + * GtkEntryCompletion::text-column: + * + * The column of the model containing the strings. + * + * Since: 2.6 + */ + g_object_class_install_property (object_class, + PROP_TEXT_COLUMN, + g_param_spec_int ("text_column", + P_("Text column"), + P_("The column of the model containing the strings."), + -1, + G_MAXINT, + -1, + G_PARAM_READWRITE)); g_type_class_add_private (object_class, sizeof (GtkEntryCompletionPrivate)); } @@ -358,6 +375,7 @@ gtk_entry_completion_set_property (GObject *object, GParamSpec *pspec) { GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (object); + GtkEntryCompletionPrivate *priv = GTK_ENTRY_COMPLETION_GET_PRIVATE (completion); switch (prop_id) { @@ -371,6 +389,10 @@ gtk_entry_completion_set_property (GObject *object, g_value_get_int (value)); break; + case PROP_TEXT_COLUMN: + priv->text_column = g_value_get_int (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -396,6 +418,10 @@ gtk_entry_completion_get_property (GObject *object, g_value_set_int (value, gtk_entry_completion_get_minimum_key_length (completion)); break; + case PROP_TEXT_COLUMN: + g_value_set_int (value, gtk_entry_completion_get_text_column (completion)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1021,8 +1047,9 @@ gtk_entry_completion_delete_action (GtkEntryCompletion *completion, * to have a list displaying all (and just) strings in the completion list, * and to get those strings from @column in the model of @completion. * - * This functions creates and adds a GtkCellRendererText for the selected column. - + * This functions creates and adds a #GtkCellRendererText for the selected + * column. + * * Since: 2.4 */ void @@ -1042,6 +1069,26 @@ gtk_entry_completion_set_text_column (GtkEntryCompletion *completion, gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion), cell, "text", column); + + g_object_notify (completion, "text_column"); +} + +/** + * gtk_entry_completion_get_text_column: + * @completion: a #GtkEntryCompletion + * + * Returns the column in the model of @completion to get strings from. + * + * Return value: the column containing the strings + * + * Since: 2.6 + **/ +gint +gtk_entry_completion_get_text_column (GtkEntryCompletion *completion) +{ + g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion)); + + return completion->priv->text_column; } /* private */ diff --git a/gtk/gtkentrycompletion.h b/gtk/gtkentrycompletion.h index aed8165070..1a3cacf499 100644 --- a/gtk/gtkentrycompletion.h +++ b/gtk/gtkentrycompletion.h @@ -102,6 +102,7 @@ void gtk_entry_completion_delete_action (GtkEntryComplet /* convenience */ void gtk_entry_completion_set_text_column (GtkEntryCompletion *completion, gint column); +gint gtk_entry_completion_get_text_column (GtkEntryCompletion *completion); G_END_DECLS -- 2.30.2